﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Contracts;
using ViewModel;

namespace View
{
	/// <summary>
	/// Logique d’interaction pour WindowAddContact.xaml
	/// </summary>
	public partial class WindowAddContact : Window
	{
	    private ContactViewModel ViewModel;

		public WindowAddContact()
		{
			this.InitializeComponent();
            ViewModel = new ContactViewModel();
		    DataContext = ViewModel;
		}

        public void SetContact(Contact theContact)
        {
            this.ViewModel.CurrentContact = theContact;
            this.textBoxMail.IsEnabled = false;
        }

        private void buttonCancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void buttonEditAddContact_Click(object sender, RoutedEventArgs e)
        {
            string mail = this.textBoxMail.Text;
            string alias = this.textBoxAlias.Text;
            string group = this.comboGroup.SelectedValue.ToString();
            bool blocked = (bool)this.checkBoxBlockContact.IsChecked.Value;

            if(this.ViewModel.AddContact(mail, alias, group, blocked))
                this.Close();
        }

	}
}